﻿using Simple.Tools.SnowFlake;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/*********************************************************
 * 命名空间 Simple.Common
 * 接口名称 WholeEntity
 * 开发人员：11920
 * 创建时间：2023/5/4 10:46:51
 * 描述说明：
 * 更改历史：
 * 
 * *******************************************************/
namespace Simple.Tools
{
	/// <summary>
	/// 
	/// </summary>
	/// <typeparam name="TKey"></typeparam>
	public class ComplexEntity<TKey>:BaseEntity<TKey>
	{
		/// <summary>
		/// 
		/// </summary>
		public ComplexEntity() 
		{ 
		
		}

		private bool isDelete = false;
		private long concurrencyStamp;
		private DateTime creationTime;
		private DateTime deletionTime;
		private long creatorID;
		private DateTime lastModificationTime;
		private long lastModifierID;
		private long deleterID;

		/// <summary>
		/// 修改标记--防止并发冲突
		/// </summary>
		public long ConcurrencyStamp { get { return concurrencyStamp; } set { concurrencyStamp = value; } }
		/// <summary>
		/// 创建时间
		/// </summary>
		public DateTime CreationTime { get { return creationTime; } set { creationTime = value; } }

		/// <summary>
		/// 创建者Id
		/// </summary>
		public long CreatorID { get { return creatorID; } set { creatorID = value; } }
		/// <summary>
		/// 最后跟新时间
		/// </summary>
		public DateTime LastModificationTime { get { return lastModificationTime; } set { lastModificationTime = value; } }

		/// <summary>
		/// 最后修改的id
		/// </summary>
		public long LastModifierID { get { return lastModifierID; } set { lastModifierID = value; } }
		/// <summary>
		/// 是否删除
		/// </summary>
		public bool IsDelete { get { return isDelete; } set { isDelete = value; } }

		/// <summary>
		/// 删除者id
		/// </summary>
		public long DeleterID { get { return deleterID; } set { deleterID = value; } }
		/// <summary>
		/// 删除时间
		/// </summary>
		public DateTime DeletionTime { get { return deletionTime; } set { deletionTime = value; } }

		/// <summary>
		/// 
		/// </summary>
		/// <param name="Id"></param>
		public void Update(long Id)
		{
			LastModificationTime = DateTime.Now;
			LastModifierID = Id;
			ConcurrencyStamp = Worker.Builder().NextId();
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="Id"></param>
		public void Add(long Id)
		{
			LastModifierID = Id;
			LastModificationTime=DateTime.Now;
			CreationTime = DateTime.Now;
			CreatorID = Id;
			ConcurrencyStamp = Worker.Builder().NextId();
		}

	}
}
